<?php
if ( is_single() ) {
  $tags = wp_get_post_tags($post->ID);
    if ($tags) {
    $first_tag = $tags[0]->term_id;
    $args=array(
      'tag__in' => array($first_tag),
      'post__not_in' => array($post->ID),
      'showposts'=>6
    );
    $my_query = new WP_Query($args);
    if( $my_query->have_posts() ) {
      while ($my_query->have_posts()) : $my_query->the_post(); ?>
      	<div class="refproject-relatedbox">
			<a href="<?php the_permalink(); ?>">
				<img src="<?php the_post_thumbnail(); ?>" alt="<?php meta('RPCustomer'); ?>" />
				<h4><?php meta('RPCustomer'); ?></h4>
				<p><?php meta('RPDate'); ?></p>
				<p class="refproject-button">View Project Details</p>
			</a>
		</div>
       <?php
      endwhile;
  wp_reset_query();  Restore global post data stomped by the_post().
} if (is_single())
?>